charset="UTF-8"

Ext.onReady(function(){

        var doctorRecord = Ext.data.Record.create([
				{name:'id'},  
              {name:'username'},
             {name:'name'},
              {name:'sex'},  
              {name:'birthday',type : 'date', dateFormat : 'm-d-Y' },  
              {name:'title'},
              {name:'graduation'},  
              {name:'jobtime',type : 'date', dateFormat : 'm-d-Y'},  
               {name:'introduction'},
               {name:'avgRank'}
		]);
    // create the data store
    var doctorStore = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({  
                	url:"queryDoctorByPageAndNamePublic.action",  
                    method:"post"  
                }),  
        reader : new Ext.data.JsonReader({
        	totalProperty : 'totalProperty',
        	root : 'doctorVOList'
        	 }, 
        	 doctorRecord
        	 ),
        	 baseParams:{departmentId:Ext.getDom("departmentId").innerHTML}
    });



    // Custom rendering Template
    var resultTpl = new Ext.XTemplate(
        '<tpl for="."><div class="search-item">',
            '<h3>{name}</h3><br>{sex}<br>{title}<br>从医时间：{jobtime:date("Y-m-d")}<br>评价:{avgRank}',
        '</div></tpl>'
    );
    
    var search = new Ext.form.ComboBox({
        store: doctorStore,
        displayField:'name',
        typeAhead: false,
        loadingText: '查询中...',
        width: 770,
        pageSize:10,
        minChars:0,
        hideTrigger:true,
        tpl: resultTpl,
        applyTo: 'search',
        itemSelector: 'div.search-item',
        onSelect: function(record){ // override default onSelect to do redirect
            window.location =
                String.format('queryDoctorByIdPublic.action?avgRank={0}&doctorId={1}', record.data.avgRank, record.data.id);
        }
    });
});